<template>
	<view class="home-wrap u-m-b-20">
		<base-nav-bar :isBack="true" :background="{'background':'#fff'}">
			<text
				slot="content"
				style="color: #333; width: 100%; text-align: center;padding-left: 20rpx;"
			>
				上传记录
			</text>
		</base-nav-bar>
		<!-- 课程预约记录 -->
		<view class="content-box"  v-if="!isEmpty" style="margin-top: 20rpx;">
			<view class="u-flex u-flex-column u-flex-between merchant-box u-p-t-20 u-m-l-30 u-m-r-30 u-m-b-20" v-for="(item,index) in courseList" :key="index"
			      @click="jump('/pages-merchant/points/prestoreDetail?tel='+item.phone+'&score='+item.score+'&images='+item.image)">
				<view class="course-item u-flex u-flex-between u-flex-items-start u-p-l-20 u-p-b-20 u-p-r-20">
					<view class="u-flex u-flex-start u-flex-items-center u-flex-3">
						<image :src="HTTP_IMG_URL()+'/merchant/points/jifen.png'" class="merchant-logo"></image>
						<view class="u-flex u-flex-items-start u-flex-column u-flex-between u-m-l-20" style="height: 80rpx;">
							<view class="course-item-text">{{item.phone}}</view>
							<view class="course-item-number">预约时间:{{item.createtime}}</view>
						</view>
					</view>
					<view class="course-item-btn-group u-flex u-flex-1 u-flex-column u-flex-around">
						<view class="course-item-btn edit">+{{item.score}}</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 数据为空 -->
		<u-empty
			v-if="isEmpty"
			mode="data"
			:marginTop="220"
			text="暂无上传记录"
		>
		</u-empty>
		<!-- 更多 -->
		<u-loadmore v-if="!isEmpty" height="80rpx" :status="loadStatus" icon-type="flower" color="#ccc"/>
	</view>
</template>

<script>
let systemInfo = uni.getSystemInfoSync();
let menuButtonInfo = {};
// #ifdef MP-WEIXIN || MP-BAIDU || MP-TOUTIAO || MP-QQ
menuButtonInfo = uni.getMenuButtonBoundingClientRect();
// #endif
import { mapGetters } from 'vuex';
import { HTTP_IMG_URL } from '../../config/app.js'
import BaseNavBar from "../../components/BaseNavBar.vue";
export default {
	components: {
		BaseNavBar
	},
	data() {
		return {
			courseList:[
				{
					logo: "/static/images/merchant/course/course_bg.png",
					name: "南彩路淘玩生活馆",
					phone: "0703-0078653",
					address: "深圳市福田区文化东路与科技大道",
					introduction: "课程:羽毛球小班课培训(4-6人)、羽毛球一对二进阶课私教培训、羽毛球一对一培训…",
					time: "08:00～20:00"
				},
				{
					logo: "/static/images/merchant/course/course_bg.png",
					name: "南彩路淘玩生活馆",
					phone: "0703-0078653",
					address: "深圳市福田区文化东路与科技大道",
					introduction: "课程:羽毛球小班课培训(4-6人)、羽毛球一对二进阶课私教培训、羽毛球一对一培训…",
					time: "08:00～20:00"
				}
			],
			loadStatus   : 'nomore', //loadmore-加载前的状态，loading-加载中的状态，nomore-没有更多的状态
			currentPage  : 1,
			lastPage     : 1,
			total  : '',
			isEmpty      : false,
		};
	},
	computed: {
		...mapGetters(['isLogin', 'userInfo']),
		customBar() {
			let statusBarHeight = systemInfo.statusBarHeight;
			console.log("====statusBarHeight",statusBarHeight)
			// #ifndef MP
			return systemInfo.platform == 'android' ? statusBarHeight + 50 : statusBarHeight + 45;
			// #endif
			// #ifdef MP-WEIXIN
			return menuButtonInfo.bottom + menuButtonInfo.top - statusBarHeight;
			// #endif
			// #ifdef MP-ALIPAY
			return statusBarHeight + systemInfo.titleBarHeight;
			// #endif
		}
	},
	onPullDownRefresh() {
	
	},
	
	onShow() {
		if(!this.isLogin){
		
		}
		
	},
	onHide() {
	},
	onLoad() {
		this.courseList = [];
		this.currentPage = 1;
		this.getMourserList()
	},
	created() {
		// 触底监听
		uni.$on('uOnReachBottom', data => {
			if (this.loadStatus == 'loadmore') {
				this.currentPage += 1;
				this.getMourserList();
			}
		});
	},
	methods: {
		HTTP_IMG_URL() {
			return HTTP_IMG_URL
		},
		// 路由跳转
		jump(path, parmas) {
			uni.navigateTo({
				url: path,
				query: parmas
			});
		},
		// 消费列表
		getMourserList() {
			let that = this;
			that.$Api.merchant.merchantScoreList({
				page    : that.currentPage,
				pageSize: 20
			}).then(res => {
				that.courseList = [...that.courseList, ...res.data.data];
				that.isEmpty     = !that.courseList.length;
				that.loadStatus  = that.currentPage < res.data.last_page ? 'loadmore' : 'nomore';
			});
		},
	}
};
</script>

<style lang="scss" scoped>
/* 注意要写在第一行，同时给style标签加入lang="scss"属性 */
.home-wrap {
	min-height: 100vh;
	background: #F6F6F8;
}
.kehu-item {
	border-radius: 20rpx;
	width: 100%;
	.swipers{
		width: 100%;
	}
}
.nickname{
	font-size: 34rpx;
	font-weight: bold;
}
.course-add{
	position: fixed;
	background: #F6F6F8;
	z-index: 1000;
	width: calc(100% - 60rpx);
	.course-add-btn{
		background: linear-gradient( 270deg, #20CE83 0%, #9FF79A 100%);
		border-radius: 8px;
		width: 100%;
		height: 80rpx;
		.course-add-icon{
			width: 40rpx;
			height: 40rpx;
		}
		.course-add-txt{
			color: #fff;
			font-size: 30rpx;
		}
	}
}

.content-box{
	.merchant-box{
		background:linear-gradient( 180deg, #E8FFED 0%,#FFFFFF 30%, #FFFFFF 100%);
		box-shadow: 0px 0px 6px 0px rgba(0,0,0,0.1), inset 0px 1px 0px 0px #FFFFFF;
		border-radius: 30rpx;
		position: relative;
		.course-item{
			width: 100%;
			margin: 0rpx 0rpx 20rpx;
			.merchant-logo{
				width: 80rpx;
				height: 80rpx;
			}
			.merchant-icon{
				width: 30rpx;
				height: 30rpx;
			}
			.course-item-text{
				font-weight: 400;
				font-size: 32rpx;
				color: #000000;
				margin-left: 10rpx;
			}
			.course-item-number{
				font-weight: 400;
				font-size: 26rpx;
				color: #9A9A9A;
				margin-left: 10rpx;
			}
			.course-item-btn-group{
				.course-item-btn{
					text-align: right;
					font-weight: 500;
					font-size: 28rpx;
					color: #30AA4D;
				}
			}
		}
		
	}
}
</style>
